import { initFrameConfigs } from '@zm-pkg/pages'
import routes from '~pages'
import { Router } from "vue-router"
import msg from '@locales'
import { STRUCTURE } from './structure'
import { UiSize } from '@zm-pkg/ui'

export function initConfig() {
  return initFrameConfigs({
    isProd: import.meta.env.PROD,
    router: {
      // router: routes,
      virtualRoute: routes,
      useHash: true,
      // routerGuard(router: Router) {
      //   router.beforeEach((to, from, next) => {
      //     console.log(to, 'to')
      //     next()
      //   })
      // },
    },
    // 国际化
    localeMsg: { ...msg },
    http: {
      BaseURL: import.meta.env.PROD ? '' : '',
      okCode: 0
    },
    dict: {
      api: '/api-common/dict',
      label: 'itemValue',
      value: 'itemCode'
    },
    structure: STRUCTURE,
    pages: {
      queryColumnApi: '/api-common/queryColumnByCode',
      downloadUrl: {
        api: '/api-file/file/download',
        type: 'get'
      },
      uploadUrl: '/api-file/file/upload'
    },
    ui: {
      form: {
        dialogColspan: {
          md: 12,
          xl: 12,
          xxl: 8
        },
        rowProps: {
          gutter: 10
        }
      },
      table: {
        defaultPageSize: 20,
        multipleSorter: false,
        exportTable: ['select', 'current']
      }
    }
  }, {
    headOptions: {
      size: UiSize.MIDDLE,
    },
    footerOptions: {
      show: true
    },
    menuOptions: {
      mixSideTrigger: 'hover'
    },
    routeReuse: {
      position: 'normal'
    }
  })
}
